$(function ()
{
    findById();
    findProject();
})

function findById()
{
    let id = sessionStorage.getItem("onlineid");

    let data = publivAjax('/back/online/findById', {id: id}, 'get');

    if (data != null)
    {
        let model = data.model;
        $("#name").val(model.name);
        $("#phone").val(model.phone);
        $("#startDate").val(model.startDate);
        $("#endDate").val(model.endDate);
        $("#roomType").val(model.roomType);
        $("#idea").val(model.idea);
    }
}

function save()
{
    let msg = {}
    let id = sessionStorage.getItem("onlineid");

    msg.id = id;
    msg.name = $.trim($("#name").val());
    msg.phone = $.trim($("#phone").val());
    msg.startDate = $.trim($("#startDate").val());
    msg.endDate = $.trim($("#endDate").val());
    msg.roomType = $.trim($("#roomType").val());
    msg.idea = $.trim($("#idea").val());

    let data = publivAjax('/back/online/edit', msg, 'post');

    if (data.count == 1)
    {
        $('#b-right').load('/back/online/onlineList.html');
    }
    else
    {
        alert("修改失败！");
    }
}